import { defineStore } from 'pinia'

export const useAside =defineStore('main',{
    state:()=>({
           // 控制侧边栏展开收起变量
        isCollapse:true,
        // 面包屑数据
        currentMenu:null,
        // 侧边栏数据
        tabList:[
            {
                path: '/',
                name: 'home',
                label: '首页',
                icon: 'house',
            },
        ]
    }),
    actions:{
        // 控制侧边栏展开收起方法
        updateIscollapse(){
            this.isCollapse = !this.isCollapse
        },
        // 更新面包屑数据
        selectMenu(val){
            console.log(val);
            if(val.name == 'home'){
                this.currentMenu =null
            }else{
                this.currentMenu=val
                let res= this.tabList.findIndex(item =>item.name == val.name )
                res == -1 ? this.tabList.push(val) : ''
            }
        },
        // 删除tag标签
        closeTag(val){
            let res = this.tabList.findIndex(item => item.name==val.name)
            this.tabList.splice(res,1)
        }
    },
    persist:true
})